home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************************/
- /* */
- /* write.c - write request processing. */
- /* */
- /* Richard W. Mincher. February 19, 1990. */
- /* */
- /* Copyright © 1990 Apple Computer, Inc. All rights reserved. */
- /* */
- /********************************************************************************/
-
- #include "AROSE.h"
- #include "os.h"
- #include "managers.h"
-
- #include "ARDriver.h"
- #include "ARTask.h"
-
- WriteCall()
- {
- #ifdef DEBUG
- printf("Write received. mDataPtr = %x, mDataSize = %x\n",
- msg->mDataPtr, msg->mDataSize );
- #endif DEBUG
-
- // Initialize internal data.
-
- G->writeCmd = 1;
-
- msg->mOData[0] = msg->mDataSize;
- msg->mOData[1] = msg->mDataPtr;
- msg->mNext = 0;
-
- // Place on waiting queue.
-
- if (G->txQHead)
- {
- G->txQTail->mNext = msg;
- G->txQTail = msg;
- return;
- }
-
- G->txQHead = msg;
- G->txQTail = msg;
- TickleWrite();
- }
-
- TickleWrite()
- {
- short s;
- message *m;
- tid_type temp;
- short count;
-
- if (G->txQHead->mOData[0] == 0)
- {
- m = G->txQHead;
- G->txQHead = G->txQHead->mNext;
- temp = m->mTo;
- m->mTo = m->mFrom;
- m->mFrom = temp;
- m->mCode |= 1;
- Send( m );
- }
-
- if (G->txQHead && (count = G->txMax - G->txCount))
- {
- if (count > G->txQHead->mOData[0])
- count = G->txQHead->mOData[0];
-
- if (count > (G->txLast - G->txIn))
- {
- NetCopy( G->txQHead->mFrom, (char *)(G->txQHead->mOData[1]),
- G->txQHead->mTo, G->txIn, G->txLast - G->txIn );
- count -= G->txLast - G->txIn;
- s = Spl(7);
- G->txCount += G->txLast - G->txIn;
- G->sTxCount += G->txLast - G->txIn;
- (void)Spl(s);
- G->txQHead->mOData[0] -= G->txLast - G->txIn;
- G->txQHead->mOData[1] += G->txLast - G->txIn;
- G->txIn = G->txFirst;
- }
-
- NetCopy( G->txQHead->mFrom, (char *)(G->txQHead->mOData[1]),
- G->txQHead->mTo, G->txIn, count);
- s = Spl(7);
- G->txCount += count;
- G->sTxCount += count;
- (void)Spl(s);
- G->txIn += count;
- if (G->txIn == G->txLast)
- G->txIn = G->txFirst;
- G->txQHead->mOData[0] -= count;
- G->txQHead->mOData[1] += count;
-
- }
-
- s = Spl(7);
- count = G->txCount;
- if (G->txQHead)
- {
- if (count < TICKLESIZE)
- G->txTickle = count;
- else
- G->txTickle = TICKLESIZE;
- }
- else
- G->writeCmd = 0;
- G->txTickle = 0;
-
- // Start Transmitter here if necessary
-
- if (!G->moreTx && G->txCount)
- tbeint();
- (void)Spl(s);
- }
-